import { randomTxtLibrary } from '../../utils/data';
import { host } from '../global.config';
import { TestConfigEntity } from '../test.entity';
const title = `自动化测试用户故事${randomTxtLibrary('number', 1)}`;
const projectName = '自动化测试项目5';
const placeholder = 'DHQO';
export const AgileAddBacklogCConfig: TestConfigEntity = {
  title: 'Agile模块添加用户故事测试',
  pageUrl: `${host.url}/agile/projects`, // 访问Agile
  screenshotName:'agile_add_backlog_tests',
  projectName: projectName, // 项目名称
  placeholder: placeholder, // 项目唯一标识
  operation: {
    type: 'click',
    name: 'addProjectBut',
    selector: 'button span:has-text("新建")',
    boxSelector: '.action-menu',
    list_selector: '.action-menu-item span',
    value: ['用户故事'],
  },
  from: [
    {
      type: 'fill',
      name: 'title',
      selector: '#title > input',
      label: '标题',
      value: title,
      err_msg: ['标题不能为空'],
    },
    {
      type: 'select',
      name: 'selectProject',
      label: '所属项目',
      selector: '.thy-select[name="selectProject"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item span',
      value: [projectName],
      err_msg: ['所属项目不能为空'],
    },
    {
      type: 'select',
      name: 'selectParentId',
      label: '所属特性',
      search: {
        selector: '.thy-select[name="selectParentId"] input',
        value: '1111'
      },
      selector: 'styx-auto-select[name="selectParentId"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item span',
      value: ['1111']
    },
    {
      type: 'select',
      name: 'selectMember',
      label: '负责人',
      selector: '.thy-select[name="selectMember"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item div',
      value: ['admin'],
    },
    {
      type: 'picke',
      name: 'start',
      selector: '.thy-calendar-picker[name="start"]',
      label: '开始时间',
      value: '2021-8-15 13:59',
      boxSelector: '.thy-calendar-picker-container',
    },
    {
      type: 'picke',
      name: 'due',
      selector: '.thy-calendar-picker[name="due"]',
      label: '截止时间',
      value: '2021-8-15 13:59',
      boxSelector: '.thy-calendar-picker-container',
    },
    {
      type: 'select',
      name: 'priority',
      label: '优先级',
      selector: '.thy-select[name="priority"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item span',
      value: ['较高']
    },
    {
      type: 'select',
      name: 'riskProperty',
      label: '风险',
      selector: '.thy-select[name="riskProperty"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item span',
      value: ['中']
    },
    {
      type: 'fill',
      name: 'field-effort',
      label: '故事点',
      selector: 'input[name="field-effort"]',
      value: '1.5',
    },
    {
      type: 'select',
      name: 'backlogType',
      label: '需求类型',
      selector: '.thy-select[name="backlogType"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item span',
      value: ['功能需求']
    },
    {
      type: 'select',
      name: 'reason',
      label: '需求来源',
      selector: '.thy-select[name="reason"]',
      boxSelector: '.thy-select-dropdown-options',
      list_selector: '.thy-option-item span',
      value: ['用户反馈']
    },
    {
      type: 'click',
      name: 'okBtn',
      selector: 'button:has-text("确认")',
    },
  ],
  testPage: {
    pageUrl: `${host.url}/agile/projects`, // 访问项目首页看列表中是否存在创建的项目
    btnGroup: [
      {
        type: 'click',
        name: 'sortBtn',
        selector: '.nav-link span:has-text("工作项")',
        delay: 2000,
      },
      {
        type: 'click',
        name: 'sortBtn',
        selector: 'a[thytooltip="排序"]',
      },
      {
        type: 'click',
        name: 'create_at',
        selector: '.action-menu-item .name:has-text("创建时间")',
      },
    ],
    table: {
      selector: 'table',
      result: [
        {label: '标题', value: title},
        {label: '负责人', value: 'admin'},
        {label: '优先级', value: '较高'},
        {label: '开始时间', value: '8月15日'},
        {label: '截止时间', value: '8月15日'},
      ],
    },
  },
};
